//
//  LocalStreamComponent.swift
//  Hermes
//
//  Created by FH on 2021/1/17.
//  Copyright © 2021 Agora. All rights reserved.
//

import Foundation
// TODO: remove
class LocalStreamComponent {
    private let appContext = HermesContext()
    private var canvasItem = VideoCanvasItem()
    
    init() {
        self.dataBinding()
    }
    
    func dataBinding() {
        // TODO: remote videos grid > 36，联动更新宽 459 -> 300
    }
    
    func layoutViews(yoga: FLContext, _ superView: NSView) {
        canvasItem.bgView = FLCommonView()
        canvasItem.bgView.bind(to: yoga, superView) { it in
            it.marginBottom = constVideoItemMarginDim.toFLValue()
        }

        let dim = constLocalStreamPanelDim
        canvasItem.videoPanel = NSView()
        canvasItem.videoPanel.bind(to: yoga, canvasItem.bgView) { it in
            it.width = FLValue(dim)
            it.height = FLValue(dim)
            it.justify = .center
            it.alignItems = .center
        }
        canvasItem.videoPanel.flBackgroundColor = .lightGray

        canvasItem.lblIndex = FLLabel()
        canvasItem.lblIndex.bind(to: yoga, canvasItem.videoPanel)
        canvasItem.lblIndex.alignment = .center
        canvasItem.lblIndex.font = NSFont.systemFont(ofSize: 12)
        canvasItem.lblIndex.flText = "local"
        
        canvasItem.lblUID = FLLabel()
        canvasItem.lblUID.bind(to: yoga, canvasItem.bgView) { it in
            it.width = FLValue(dim)
            it.height = constRemoteUidHeight.toFLValue()
        }
        canvasItem.lblUID.font = NSFont.systemFont(ofSize: 10)
        canvasItem.lblUID.flText = "uid: ..."
        canvasItem.lblUID.flBackgroundColor = .gray
        
        canvasItem.coverView = NSView()
        canvasItem.coverView.bind(to: yoga, canvasItem.bgView) { it in
            it.position = .absolute
            it.left = 0
            it.top = 0
            it.width = FLValue(dim)
            it.height = FLValue(dim)
        }
    }
}
